﻿@model SysRole
<form class="layui-form layui-form-pane" lay-filter="">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <div class="layui-input-inline">
            <input type="text" name="RoleName" autocomplete="off" class="layui-input" lay-verify="required" maxlength="20" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色描述</label>
        <div class="layui-input-inline">
            <input type="text" name="RoleDesc" autocomplete="off" class="layui-input" lay-verify="required" maxlength="50" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色排序</label>
        <div class="layui-input-inline">
            <input type="text" name="RoleSort" autocomplete="off" class="layui-input" lay-verify="number" />
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="text-align:right;">
            <button class="layui-btn" lay-submit lay-filter="save">保存</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    layui.use(['form', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        form.val('', {
            "RoleName": "@Model.RoleName",
            "RoleDesc": "@Model.RoleDesc",
            "RoleSort": "@Model.RoleSort",
        });

        form.on("submit(save)", function (formdata) {
            formdata.field.ID = "@Model.ID";
            $.ajax({
                url: 'Edit',
                data: formdata.field,
                success: function (res) {
                    layer.alert(res.msg, function (index) {
                        layer.close(index);
                        if (res.count > 0) {
                            parent.layer.closeAll();
                        }
                    })
                }
            });
            return false;
        })
    })
</script>